package org.example.org.example

import org.example.Person
import org.example.PersonDatabase

class PersonRepositoryImp(val driverFactory: DatabaseDriverFactory) : PersonRepository {
    private var database: PersonDatabase

    init {
        val driver = driverFactory.createDriver()
//        PersonDatabase.Schema.create(driver)
        database = PersonDatabase(driver)
    }

    override fun insertPerson(name: String, age: Long) {
        database.personQueries.insertPerson(name, age)
    }

    override fun selectAllPeople(): List<Person> {
        return database.personQueries.selectAllPeople().executeAsList()
    }
}